#include <iostream>
using namespace std;
#include <vector> 
#include <string>





int process(string& str , int L , int R)
{
  if (L == R)
  {
    return 1;
  }

  if (L == R - 1)
  {
    return str[L] == str[R] ? 2 : 1;
  }

  int p1 = process(str , L + 1 , R);
  int p2 = process(str , L , R - 1);
  int p3 = str[L] == str[R] ? 2 + process(str , L + 1, R - 1) : 0;

  return max(max(p1 , p2) , p3);
}



int process1(string& str ,  vector<vector<int>>& dp)
{
  for (int L = 0; L < str.size(); L++)
  {
    for(int R = L; R < str.size(); R++)
    {
      if (L == R)
      {
        dp[L][R] = 1;
      }

      if (L == R-1) 
      {
        dp[L][R] = str[L] == str[R] ? 2 : 1;
      }
    }
  }

  for (int L = 0; L < str.size(); L++)
  {
    for(int R = L + 2; R < str.size(); R++)
    {
      int p1 = dp[L+1][R];
      int p2 = dp[L][R-1];
      int p3 = str[L] == str[R] ? 2 + dp[L+1][R-1] : 0;

      dp[L][R] = max(p1 , max(p2 , p3));
    }
  }

  return dp[0][str.size()-1];
}



int main()
{

  return 0;
}
